
*****************************************************

* 	This do-file provides a replication of the analyses presented in Van Hauwaert & English "Responsiveness and the macro‐origins of immigration opinions: Evidence from Belgium, France and the UK", in Comparative European Politics (2018)

* 	Steven M. Van Hauwaert, University of Mainz *
*****************************************************


****************************************************
// FIGURE 1 //
****************************************************


bysort region: egen mean_imm = mean(imputed_foreignborn)
bysort region: egen mean_poim = mean(poim)
label var mean_poim "Average immigration opinions, per region"

twoway scatter mean_poim mean_imm, mlabel(region) || lfit mean_poim mean_imm
graph save Graph "/.../Figure1.1.gph"

scatter mean_poim mean_imm if region != "London" & region != "Brussels" & region != "Ile de France", mlabel(region) || lfit mean_poim mean_imm if region != "London" & region != "Brussels" & region != "Ile de France", mlabel(region)
graph save Graph "/.../Figure1.2.gph"

graph combine "Figure1.1.gph" "Figure1.2.gph"
graph save Graph "/.../Figure1.gph"


****************************************************
// FIGURE 2 //
****************************************************


graph twoway (line bxl year, sort) if year > 1989 & year < 2016
graph twoway (line fla year, sort) if year > 1989 & year < 2016
graph twoway (line wal year, sort) if year > 1989 & year < 2016

graph combine "fig2_fla.gph" "fig2_wal.gph" "fig2_bxl.gph", ycommon 
graph save Graph "/.../fig2_be.gph"


****************************************************
// FIGURE 3 //
****************************************************


graph twoway (line bp year, sort) if year > 1987
graph twoway (line centrest year, sort) if year > 1987
graph twoway (line est year, sort) if year > 1987
graph twoway (line idf year, sort) if year > 1987
graph twoway (line med year, sort) if year > 1987
graph twoway (line npdc year, sort) if year > 1987
graph twoway (line ouest year, sort) if year > 1987
graph twoway (line sudouest year, sort) if year > 1987

graph combine "fig3_bp.gph" "fig3_centrest.gph" "fig3_est.gph" "fig3_idf.gph" "fig3_med.gph" "fig3_npdc.gph" "fig3_ouest.gph" "fig3_sudouest.gph", ycommon
graph save Graph "/.../fig3_fr.gph"


****************************************************
// FIGURE 4 //
****************************************************


graph twoway (line east year, sort) if year > 1982 & year < 2016
graph twoway (line eastmid year, sort) if year > 1982 & year < 2016
graph twoway (line london year, sort) if year > 1982 & year < 2016
graph twoway (line northeast year, sort) if year > 1982 & year < 2016
graph twoway (line north_ire year, sort) if year > 2002 & year < 2016
graph twoway (line northwest year, sort) if year > 1982 & year < 2016
graph twoway (line scotland year, sort) if year > 1982 & year < 2016
graph twoway (line southeast year, sort) if year > 1982 & year < 2016
graph twoway (line southwest year, sort) if year > 1982 & year < 2016
graph twoway (line wales year, sort) if year > 1982 & year < 2016
graph twoway (line westmid year, sort) if year > 1982 & year < 2016
graph twoway (line yorkhum year, sort) if year > 1982 & year < 2016

graph combine "fig4_east.gph" "fig4_eastmid.gph" "fig4_london.gph" "fig4_northeast.gph" "fig4_ni.gph" "fig4_northwest.gph" "fig4_scotland.gph" "fig4_southeast.gph" "fig4_southwest.gph" "fig4_wales.gph" "fig4_westmid.gph" "fig4_yorkhum.gph", ycommon 
graph save Graph "/.../fig4_uk.gph"


****************************************************
// TABLE 1 //
****************************************************


gen log_poim = log(poim)

xtgls poim imputed_foreignborn imputed_unemployment i.countryid if regionid != 106 & year < 2015, corr(ar1)
durbina2 

xtgls poim imputed_foreignborn imputed_unemployment population_1000 size_1000 riascore elderly imputed_education_labour imputed_life_expect i.countryid if regionid != 106 & year < 2015, corr(ar1)
durbina2 

prais poim imputed_foreignborn imputed_unemployment i.countryid if regionid != 106 & year < 2015, corc
durbina2 

prais poim imputed_foreignborn imputed_unemployment population_1000 size_1000 riascore elderly imputed_education_labour imputed_life_expect i.countryid if regionid != 106 & year < 2015, corc
durbina2 

xtpcse poim imputed_foreignborn imputed_unemployment i.countryid if regionid != 106 & year < 2015, corr(psar1)
durbina2 

xtpcse poim imputed_foreignborn imputed_unemployment population_1000 size_1000 riascore elderly imputed_education_labour imputed_life_expect i.countryid if regionid != 106 & year < 2015, corr(psar1)
durbina2 

bootstrap, reps(1000) nowarn: xtgls poim imputed_foreignborn imputed_unemployment i.countryid if regionid != 106 & year < 2015
durbina2 

bootstrap, reps(1000) nowarn: xtgls poim imputed_foreignborn imputed_unemployment population_1000 size_1000 riascore elderly imputed_education_labour imputed_life_expect i.countryid if regionid != 106 & year < 2015
durbina2 

xtgls log_poim imputed_foreignborn imputed_unemployment i.countryid if regionid != 106 & year < 2015, corr(ar1)
durbina2 

xtgls log_poim imputed_foreignborn imputed_unemployment population_1000 size_1000 riascore elderly imputed_education_labour imputed_life_expect i.countryid if regionid != 106 & year < 2015, corr(ar1)
durbina2 


****************************************************
// FIGURE 5 //
****************************************************


gen central = .
replace central = 0 if riascore <= 10
replace central = 1 if riascore > 10

xtgls poim c.imputed_foreignborn##i.central imputed_unemployment population_1000 size_1000 elderly imputed_education_labour imputed_life_expect i.countryid if year < 2015, corr(ar1)

margins, dydx(imputed_foreignborn) at(central==0) at(central==1) 
marginsplot, scheme(plottig)


****************************************************
// TABLE 2 //
****************************************************


xtgls poim c.imputed_foreignborn##c.imputed_unemployment population_1000 size_1000 riascore elderly imputed_education_labour imputed_life_expect i.countryid if central == 1 & year < 2015, corr(ar1)

prais poim c.imputed_foreignborn##c.imputed_unemployment  population_1000 size_1000 riascore elderly imputed_education_labour imputed_life_expect i.countryid if central == 1 & year < 2015, corc

xtpcse poim c.imputed_foreignborn##c.imputed_unemployment population_1000 size_1000 riascore imputed_education_labour imputed_life_expect i.countryid if central == 1 & year < 2015, corr(psar1)

bootstrap, reps(1000) nowarn: xtgls poim c.imputed_foreignborn##c.imputed_unemployment population_1000 size_1000 riascore elderly imputed_education_labour imputed_life_expect i.countryid if central == 1 & year < 2015

xtgls log_poim c.imputed_foreignborn##c.imputed_unemployment population_1000 size_1000 riascore elderly imputed_education_labour imputed_life_expect i.countryid if central == 1 & year < 2015, corr(ar1)

******************************************************
